<?php
App::uses('AppController', 'Controller');
/**
 * SysFronts Controller
 *
 * @property SysFront $SysFront
 * @property PaginatorComponent $Paginator
 */
class SysSearchsController extends AppController {

/**
 * Components
 *
 * @var array
 */
	public $components = array('Paginator');

/**
 * admin_index method
 *
 * @return void
 */
	public function admin_index() {
		$this->SysSearch->recursive = 0;
		$this->Paginator->settings = array('order'=>'SysSearch.sort_top DESC,SysSearch.times DESC');
		$this->set('sysSearchs', $this->Paginator->paginate('SysSearch'));
	}
	/**
	 * admin_edit method
	 *
	 * @throws NotFoundException
	 * @param string $id
	 * @return void
	 */
	public function admin_edit($id = null) {
		if (!$this->SysSearch->exists($id)) {
			throw new NotFoundException(__('Invalid sys front'));
		}
		if ($this->request->is(array('post', 'put'))) {
			if ($this->SysSearch->save($this->request->data)) {
				$this->Session->setFlash('修改成功','tip/tip_float',array('t'=>'success'));
				return $this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash('修改失败','tip/tip_float',array('t'=>'error'));
			}
		} else {
			$options = array('conditions' => array('SysSearch.' . $this->SysSearch->primaryKey => $id));
			$this->request->data = $this->SysSearch->find('first', $options);
		}
		$this->loadModel('SysWebsite');
		$sysWebsites = $this->SysWebsite->find('list');
		$this->set(compact('sysWebsites'));
	}
}
